{% extends 'type_base.html' %}

{% load static %}

{% block title %}
    {{ single_type.tname }}
{% endblock %}

{% block mycss %}
    <link rel="stylesheet" type="text/css" href="{% static 'css/type_show.css' %}"/>
{% endblock %}

{% block type_class %}
    <ul class="nav flex-column">
        <li class="nav-item">
            <a class="nav-link justify-content-end" href="{% url 'shop:type_show' %}">全部</a>
        </li>
        {% for type in types %}
            <li class="nav-item">
                {% csrf_token %}
                <!-- <a class="type_class nav-link justify-content-end "
                           href="javascript:;" tag="{{ type.id }}">{{ type.tname }}</a>
                        -->
                <a class="nav-link justify-content-end"
                   href="{% url 'shop:detail_type' type.id %}">{{ type.tname }}</a>

            </li>
        {% endfor %}
    </ul>
{% endblock %}

{% block type_goods %}
    <table class="table table-hover a" style="width: 90%;" id="type-show">
        <tr>
            <td>序号</td>
            <td>上市时间</td>
            <td>名称</td>
            <td>描述</td>
            <td>价格</td>
            <td>库存</td>
            <td>销售量</td>
            <td>操作</td>
        </tr>
        {% for goods in single_type.goods_set.all %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ goods.add_time }}</td>
                <td><a href="{% url 'shop:goods_details' goods.id %}">{{ goods.name }}</a></td>
                <td>{{ goods.desc|safe }}</td>
                <td>{{ goods.price }}</td>
                <td>{{ goods.store_num }}</td>
                <td>{{ goods.sale_num }}</td>
                <td>
                    <!--设置href="javascript:;使其执行无意义语句，阻止执行跳转 -->
                    <a href="javascript:;" class="dele" tag="{{ goods.id }}">删除</a>
                    <a href="{% url 'shop:update' %}?id={{ goods.id }}">修改</a>
                </td>
            </tr>
        {% empty %}
            <tr>
                <td>还没有商品</td>
            </tr>
        {% endfor %}
    </table>

{% endblock %}

{% block myjs %}
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="{% static 'js/main.js' %}"></script>
{% endblock %}